<?php
defined('JPATH_BASE') or die;
JFormHelper::loadFieldClass('list');

class JFormFieldShopEdit extends JFormFieldList
{
    public $type = 'ShopEdit';
    
    protected function getOptions() 
    {
        $options = array();  
        
        $db = JFactory::getDbo();
	$query	= $db->getQuery(true);
        $query->select('id AS value, name as text, userId');
	$query->from('#__shops');
        $where = $this->form->getValue('id', 0) < 1 ? $where = JFactory::getUser()->id : $this->form->getValue('userId', 0);
        $query->where('userId='.$where);
        $db->setQuery($query);
	$options = $db->loadObjectList();
       
        return $options;
    }
}
?>
